package cn.wolfcode.p2p.business.domain;

import cn.wolfcode.p2p.base.domain.BaseDomain;
import cn.wolfcode.p2p.base.domain.LoginInfo;
import cn.wolfcode.p2p.util.Constants;
import lombok.Getter;
import lombok.Setter;
import org.springframework.format.annotation.DateTimeFormat;

import java.math.BigDecimal;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;

@Getter@Setter
public class PaymentSchedule extends BaseDomain {
    @DateTimeFormat(pattern = "yyyy-MM-dd")
    private Date deadline; //截止还款日期
    @DateTimeFormat(pattern = "yyyy-MM-dd")
    private Date payDate;//实际还款时间

    private BigDecimal totalAmount=Constants.ZERO;//还款总额,每期利息加本金

    private BigDecimal principal=Constants.ZERO;//本金

    private BigDecimal interest=Constants.ZERO;//利息

    private int monthIndex;//第几期

    private Integer state = Constants.PAYMENT_STATE_NORMAL;//默认还款状态正常待还

    private Integer bidRequestType;//借款类型

    private Integer returnType;//还款方式

    private Long bidRequestId;//借款ID

    private LoginInfo borrowUser;

    private String bidRequestTitle;
    private List<PaymentScheduleDetail> paymentScheduleDetails = new ArrayList<>();
    public String getStateDisplay() {
        switch (state) {
            case Constants.PAYMENT_STATE_NORMAL:
                return "正常待还";
            case Constants.PAYMENT_STATE_DONE:
                return "已还";
            case Constants.PAYMENT_STATE_OVERDUE:
                return "逾期";
            default:
                return "未知";
        }
    }
}